/**
**************************************************************************************
*Founder Effect                                                                      *
*Copyright (C) 2006-2007, 5d Studios (www.5d-Studios.com)                            *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#include "StdAfx.h"
#include "FloorSwitch.h"
#include "Player.h"
#include "EntityManager.h"

#define SWITCH_OFF (ENT_STATES[ IDLE ])
#define SWITCH_ON  (ENT_STATES[ WALKING ])


FloorSwitch::FloorSwitch(void) : IEntity()
{
    m_triggerer = NULL;
    m_flags |= EF_NOCOLLIDE;    // ents can walk over this
    m_flags |= EF_DRAWOVER;     // make sure this draws on the floor
}

FloorSwitch::~FloorSwitch(void)
{
}


/** Update the entity */
void FloorSwitch::Update( long dt)
{
    m_FSM.Update();
    
    IEntity* ent = GetActivator();
    if ( ent && !ent->GetBounds().Intersects( m_bounds ) )
    {
        SetState( SWITCH_OFF );
        m_triggerer = NULL;
    }
}

/** Collide with another entity */
bool FloorSwitch::CollideWith( IEntity* ent )
{
    SetState( SWITCH_ON );
    m_triggerer = ent;

    return false;
}